#include "descriptorManager.h"
#include "logger.h"
#include "common.h"
#include "termlist.h"


int main(int argc, char** argv) {
  log_init();
  g_log_context.log_level = LOG_DEBUG;
  int ret;

  FILE* fp = fopen(argv[1], "r");assert(fp);

  idx_index0_t index0;
  uint64_t l_sign = 0;

  while(1) {
    ret = fread(&index0, sizeof(idx_index0_t), 1, fp);
    if(ret != 1 && feof(fp)) {
      NOTICE("finish, check idx0[%s] ok", argv[1]);
      exit(0);
    }
    else if(ret != 1) assert(0);

    if(index0.tsign_l < 0 ||
	index0.tsign_l >= index0.tsign_h) {
      FATAL("idx0 error, [%s] l[%llu] h[%llu]", argv[1],
	  index0.tsign_l,
	  index0.tsign_h
	  );
      exit(-1);
    }

    if(index0.tsign_l <= l_sign) {
      FATAL("idx0 error, [%s] l[%llu] h[%llu]", argv[1],
	  index0.tsign_l,
	  index0.tsign_h
	  );
      exit(-1);
    }

    l_sign = index0.tsign_h;
    
  }

  return 0;
}

